<template>
	<view class="page">
		<Navbar :title="title"></Navbar>
		<view style="padding-bottom: 10%;">
			<view class="u-flex u-col-top u-margin-bottom-30 home-content" v-for="item in dataList" :key="item.Id"
				@click="link_to_page('/pages-home/pages/notice/detail?id=' + item.Id)">
				<view class="u-flex-1 u-padding-22">
					<view class="u-flex u-row-between u-font-28 u-font-w-6 u-padding-bottom-10 u-line-1">
						<view class="release_left"> {{ item.Title }} </view>
						<view class="release_right">
							<span v-if="item.Status == 0" style="color: #FF9C00;"> 待审核 </span>
							<span v-if="item.Status == 1" style="color:#00BD00"> 已发布 </span>
							<span v-if="item.Status == 2" style="color:#FF0000"> 已关闭 </span>
						</view>
					</view>
					<view class="u-font-36 u-line-3" style="color: #636363;">{{ item.Content }}</view>
					<view class="u-font-8 u-line-3" style="display: flex;justify-content: flex-end;">
						<u-button type="success" size="mini" v-if="item.Status == 1" @click="discardClick(item.Id)">
							召回
						</u-button>
					</view>
				</view>
			</view>
		</view>
		<u-empty text="数据为空" mode="data" v-if="!dataList.length && !dataLoading"></u-empty>
		<view class="u-flex footer-button">
			<view class="u-flex-1"><u-button type="primary" shape="circle"
					@click="link_to_page('/pages-mine/pages/release')"> 新增招聘信息 </u-button>
			</view>
		</view>
		<u-modal v-model="show" :show-cancel-button="true" :content="content" @confirm="confirmCancel()"></u-modal>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				type: 1,
				title: '我的招聘信息',
				dataList: [],
				dataLoading: false,
				show: false,
				content: ' 是否召回当前发布的招聘信息 ？',
				Zid: '',
			};
		},
		onShow() {
			this.getList();
		},
		onLoad(e) {

		},
		methods: {
			getList() {
				const token = uni.getStorageSync('USER_INFO')
				var panams = {
					filter: token.Code,
					page: 1,
					rows: 60,
					Status: 0
				}
				if (this.dataLoading) return;
				this.dataLoading = true;
				this.$u.api.PutStatusIssued(panams).then(res => {
					if (res && res.code == 0) {
						var data = [];
						this.dataList = res.data;
					}
					this.dataLoading = false;
				});
			},
			//废弃
			discardClick(id) {
				this.Zid = id;
				this.show = true
			},
			//确认
			confirmCancel() {
				this.show = false;
				var panams = {
					id: this.Zid
				}
				this.$u.api.PutStatusClose(panams).then(res => {
					if (res && res.code == 0) {
						this.getList();
						uni.showToast({
							title: '提交成功',
							icon: 'none'
						});
					}
				});
			},
		}
	};
</script>

<style lang="scss" scoped>
	.page {
		padding: 20rpx;
		background-color: #f4f5f7;
	}

	.home-content {
		min-height: 150rpx;
		position: relative;
		border-radius: 16rpx;
		background-color: #fff;
		overflow: hidden;
	}

	.footer-button {
		position: fixed;
		left: 0;
		bottom: 0;
		z-index: 100;
		width: 100%;
		height: 98rpx;
		padding: 13rpx 20rpx;
		background-color: #ffffff;
	}

	.release_left {}

	.release_right {}
</style>